/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#include <lldp/lldp.h>
#include <gtest/gtest.h>
#include <vector>
#include <string>
#include <stdexcept>
#include <cstring>
#include <arpa/inet.h>

namespace test_lldp {

class lldp_test : public ::testing::Test {
protected:
    dev::lldp lldp_parser;

    // 辅助函数：创建有效的LLDP响应头部
    std::vector<uint8_t> create_valid_header() {
        std::vector<uint8_t> header(22);  // LLDP_HEADER_LEN = 22
        auto* rsp = reinterpret_cast<dev::vdpci_lldp_response*>(header.data());

        rsp->manufacture_id = htonl(dev::MANUFACTURE_ID);
        rsp->cmd_type = dev::RSP_CMD_TYPE;
        rsp->sub_cmd = dev::RSP_SUB_CMD;
        rsp->rsv = 0;
        rsp->port_id = 1;
        rsp->dest_addr[0] = 0x01; rsp->dest_addr[1] = 0x02; rsp->dest_addr[2] = 0x03;
        rsp->dest_addr[3] = 0x04; rsp->dest_addr[4] = 0x05; rsp->dest_addr[5] = 0x06;
        rsp->src_addr[0] = 0x07; rsp->src_addr[1] = 0x08; rsp->src_addr[2] = 0x09;
        rsp->src_addr[3] = 0x0A; rsp->src_addr[4] = 0x0B; rsp->src_addr[5] = 0x0C;
        rsp->ether_type = htons(0x88CC);

        return header;
    }

    // 辅助函数：创建TLV头部
    std::vector<uint8_t> create_tlv_header(uint8_t type, uint16_t length) {
        std::vector<uint8_t> header(2);
        header[0] = (type << 1) | ((length >> 8) & 0x01);  // 高位包含长度高1bit和类型
        header[1] = length & 0xFF;  // 长度低8bit
        return header;
    }

    // 辅助函数：创建结束TLV (type=0, length=0)
    std::vector<uint8_t> create_end_tlv() {
        return create_tlv_header(0, 0);
    }

    // 辅助函数：创建完整的LLDP数据包
    std::vector<uint8_t> create_lldp_packet(const std::vector<std::vector<uint8_t>>& tlvs) {
        auto header = create_valid_header();
        std::vector<uint8_t> packet = header;

        for (const auto& tlv : tlvs) {
            packet.insert(packet.end(), tlv.begin(), tlv.end());
        }

        return packet;
    }
};

// 测试 parse 函数 - 主要公共接口
TEST_F(lldp_test, parse_valid_packet) {
    // 创建正确的TLV序列：Chassis ID, Port ID, TTL, End TLV
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 7));  // Chassis ID TLV
    tlvs.back().insert(tlvs.back().end(), {'\x04', '\x11', '\x22', '\x33', '\x44', '\x55', '\x66'});
    tlvs.push_back(create_tlv_header(2, 7));  // Port ID TLV
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(3, 2));  // TTL TLV
    tlvs.back().insert(tlvs.back().end(), {'\x00', '\x78'});
    tlvs.push_back(create_end_tlv());  // End TLV

    auto packet = create_lldp_packet(tlvs);
    auto result = lldp_parser.parse(packet);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_TRUE(result.contains("dest_addr"));
    EXPECT_TRUE(result.contains("src_addr"));
    EXPECT_TRUE(result.contains("ether_type"));
    EXPECT_TRUE(result.contains("tlvs"));
}

TEST_F(lldp_test, parse_insufficient_data_length) {
    std::vector<uint8_t> short_packet(10);  // 小于LLDP_HEADER_LEN
    EXPECT_THROW(lldp_parser.parse(short_packet), std::runtime_error);
}

TEST_F(lldp_test, parse_invalid_header) {
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 7));  // Chassis ID TLV
    tlvs.back().insert(tlvs.back().end(), {'\x04', '\x11', '\x22', '\x33', '\x44', '\x55', '\x66'});
    tlvs.push_back(create_tlv_header(2, 7));  // Port ID TLV
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(3, 2));  // TTL TLV
    tlvs.back().insert(tlvs.back().end(), {'\x00', '\x78'});
    tlvs.push_back(create_end_tlv());  // End TLV

    auto packet = create_lldp_packet(tlvs);
    auto* rsp = reinterpret_cast<dev::vdpci_lldp_response*>(packet.data());
    rsp->manufacture_id = htonl(0x12345678);  // 无效的manufacture_id

    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

// 测试 parse_ttl_tlv 函数 (通过公共接口测试)
TEST_F(lldp_test, parse_lldp_tlv_ttl_valid) {
    dev::lldp_tlv tlv{dev::tlv_type::TTL_TLV, std::string("\x00\x78", 2)};  // TTL = 120
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("ttl"));
    EXPECT_EQ(result["ttl"], 120);
}

// 测试 parse_system_name_data_tlv 函数 (通过公共接口测试)
TEST_F(lldp_test, parse_lldp_tlv_system_name_normal) {
    dev::lldp_tlv tlv{dev::tlv_type::SYSTEM_NAME_TLV, "TestSystem"};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("system_name"));
    EXPECT_EQ(result["system_name"], "TestSystem");
}

TEST_F(lldp_test, parse_lldp_tlv_system_name_too_long) {
    std::string long_name(600, 'A');
    dev::lldp_tlv tlv{dev::tlv_type::SYSTEM_NAME_TLV, long_name};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("system_name"));
    EXPECT_EQ(result["system_name"].as<std::string>().length(), 512);
}

// 测试 parse_org_specific_data_tlv 函数 (通过公共接口测试)
TEST_F(lldp_test, parse_lldp_tlv_org_specific_valid_vlan) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x80\xC2\x01\x00\x64", 6)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("vlan_id"));
    EXPECT_EQ(result["vlan_id"], 100);
}

TEST_F(lldp_test, parse_lldp_tlv_org_specific_unknown_subtype) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x80\xC2\xFF\x00\x64", 6)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.empty());  // 未知subtype不应返回vlan_id
}

// 测试 parse_lldp_tlv 函数
TEST_F(lldp_test, parse_lldp_tlv_chassis_id) {
    dev::lldp_tlv tlv{dev::tlv_type::CHASSIS_ID_TLV, std::string("\x04\x11\x22\x33\x44\x55\x66", 7)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("chassis_id"));
    EXPECT_TRUE(result.contains("chassis_id_subtype"));
    EXPECT_EQ(result["chassis_id"], "11:22:33:44:55:66");
    EXPECT_EQ(result["chassis_id_subtype"], "MacAddr");
}

TEST_F(lldp_test, parse_lldp_tlv_port_id) {
    dev::lldp_tlv tlv{dev::tlv_type::PORT_ID_TLV, std::string("\x03\x11\x22\x33\x44\x55\x66", 7)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_TRUE(result.contains("port_id_subtype"));
    EXPECT_EQ(result["port_id"], "11:22:33:44:55:66");
    EXPECT_EQ(result["port_id_subtype"], "MacAddr");
}

TEST_F(lldp_test, parse_lldp_tlv_ttl) {
    dev::lldp_tlv tlv{dev::tlv_type::TTL_TLV, std::string("\x00\x78", 2)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("ttl"));
    EXPECT_EQ(result["ttl"], 120);
}

TEST_F(lldp_test, parse_lldp_tlv_system_name) {
    dev::lldp_tlv tlv{dev::tlv_type::SYSTEM_NAME_TLV, "TestSystem"};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("system_name"));
    EXPECT_EQ(result["system_name"], "TestSystem");
}

TEST_F(lldp_test, parse_lldp_tlv_org_specific) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x80\xC2\x01\x00\x64", 6)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("vlan_id"));
    EXPECT_EQ(result["vlan_id"], 100);
}

// build_parse_result 是私有函数，通过公共接口间接测试
TEST_F(lldp_test, parse_result_structure) {
    // 通过parse函数间接测试build_parse_result
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 7));  // Chassis ID TLV
    tlvs.back().insert(tlvs.back().end(), {'\x04', '\x11', '\x22', '\x33', '\x44', '\x55', '\x66'});
    tlvs.push_back(create_tlv_header(2, 7));  // Port ID TLV
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(3, 2));  // TTL TLV
    tlvs.back().insert(tlvs.back().end(), {'\x00', '\x78'});
    tlvs.push_back(create_end_tlv());  // End TLV

    auto packet = create_lldp_packet(tlvs);

    auto result = lldp_parser.parse(packet);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_TRUE(result.contains("dest_addr"));
    EXPECT_TRUE(result.contains("src_addr"));
    EXPECT_TRUE(result.contains("ether_type"));
    EXPECT_TRUE(result.contains("tlvs"));
}

// mac_addr_to_hex_string 是内部辅助函数，通过其他测试间接覆盖

// 测试 parse_lldp_tlv 函数 - 解析单个TLV
TEST_F(lldp_test, parse_lldp_tlv_chassis_id_mac) {
    dev::lldp_tlv tlv{dev::tlv_type::CHASSIS_ID_TLV, std::string("\x04\x11\x22\x33\x44\x55\x66", 7)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("chassis_id"));
    EXPECT_TRUE(result.contains("chassis_id_subtype"));
    EXPECT_EQ(result["chassis_id"], "11:22:33:44:55:66");
    EXPECT_EQ(result["chassis_id_subtype"], "MacAddr");
}

TEST_F(lldp_test, parse_lldp_tlv_port_id_mac) {
    dev::lldp_tlv tlv{dev::tlv_type::PORT_ID_TLV, std::string("\x03\x11\x22\x33\x44\x55\x66", 7)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_TRUE(result.contains("port_id_subtype"));
    EXPECT_EQ(result["port_id"], "11:22:33:44:55:66");
    EXPECT_EQ(result["port_id_subtype"], "MacAddr");
}

TEST_F(lldp_test, parse_lldp_tlv_org_specific_vlan) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x80\xC2\x01\x00\x64", 6)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("vlan_id"));
    EXPECT_EQ(result["vlan_id"], 100);
}

TEST_F(lldp_test, parse_lldp_tlv_empty_info_string) {
    dev::lldp_tlv tlv{dev::tlv_type::CHASSIS_ID_TLV, ""};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.empty());
}

TEST_F(lldp_test, parse_lldp_tlv_unknown_type) {
    dev::lldp_tlv tlv{static_cast<dev::tlv_type>(999), "test"};  // 未知类型
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.empty());
}

// 测试常量定义
TEST_F(lldp_test, constants_defined) {
    EXPECT_EQ(dev::MANUFACTURE_ID, static_cast<uint32_t>(0x000007DB));
    EXPECT_EQ(dev::RSP_CMD_TYPE, static_cast<uint8_t>(0x00));
    EXPECT_EQ(dev::RSP_SUB_CMD, static_cast<uint8_t>(0x00));
    EXPECT_EQ(dev::LLDP_MAX_TLV_NUM, static_cast<uint32_t>(64));
    EXPECT_EQ(dev::TLV_HEADER_LEN, static_cast<uint32_t>(2));
    EXPECT_EQ(dev::org_oui_byte, std::string("\x00\x80\xC2", 3));
}

// 测试各种错误情况以提高覆盖率
TEST_F(lldp_test, parse_invalid_cmd_type) {
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 7));
    tlvs.back().insert(tlvs.back().end(), {0x04, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
    tlvs.push_back(create_tlv_header(2, 7));
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(3, 2));
    tlvs.back().insert(tlvs.back().end(), {0x00, 0x78});
    tlvs.push_back(create_end_tlv());

    auto packet = create_lldp_packet(tlvs);
    auto* rsp = reinterpret_cast<dev::vdpci_lldp_response*>(packet.data());
    rsp->cmd_type = 0xFF;  // 无效的cmd_type

    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

TEST_F(lldp_test, parse_invalid_sub_cmd) {
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 7));
    tlvs.back().insert(tlvs.back().end(), {0x04, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
    tlvs.push_back(create_tlv_header(2, 7));
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(3, 2));
    tlvs.back().insert(tlvs.back().end(), {0x00, 0x78});
    tlvs.push_back(create_end_tlv());

    auto packet = create_lldp_packet(tlvs);
    auto* rsp = reinterpret_cast<dev::vdpci_lldp_response*>(packet.data());
    rsp->sub_cmd = 0xFF;  // 无效的sub_cmd

    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

// 测试错误的TLV顺序
TEST_F(lldp_test, parse_wrong_tlv_order) {
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(2, 7));  // Port ID在第一个位置，应该报错
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(1, 7));
    tlvs.back().insert(tlvs.back().end(), {0x04, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
    tlvs.push_back(create_tlv_header(3, 2));
    tlvs.back().insert(tlvs.back().end(), {0x00, 0x78});
    tlvs.push_back(create_end_tlv());

    auto packet = create_lldp_packet(tlvs);
    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

// 测试TLV数量超过限制
TEST_F(lldp_test, parse_too_many_tlvs) {
    std::vector<std::vector<uint8_t>> tlvs;
    // 创建65个TLV，超过LLDP_MAX_TLV_NUM (64)
    for (int i = 0; i < 65; ++i) {
        tlvs.push_back(create_tlv_header(5, 1));  // System Name TLV
        tlvs.back().insert(tlvs.back().end(), {0x41});  // 'A'
    }
    tlvs.push_back(create_end_tlv());

    auto packet = create_lldp_packet(tlvs);
    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

// 测试无效的TLV长度
TEST_F(lldp_test, parse_invalid_tlv_length) {
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 1));  // Chassis ID长度不够（最小2）
    tlvs.back().insert(tlvs.back().end(), {0x04});
    tlvs.push_back(create_end_tlv());

    auto packet = create_lldp_packet(tlvs);
    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

// 测试缺少结束TLV
TEST_F(lldp_test, parse_missing_end_tlv) {
    std::vector<std::vector<uint8_t>> tlvs;
    tlvs.push_back(create_tlv_header(1, 7));
    tlvs.back().insert(tlvs.back().end(), {0x04, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
    tlvs.push_back(create_tlv_header(2, 7));
    tlvs.back().insert(tlvs.back().end(), {0x03, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC});
    tlvs.push_back(create_tlv_header(3, 2));
    tlvs.back().insert(tlvs.back().end(), {0x00, 0x78});
    // 不添加结束TLV

    auto packet = create_lldp_packet(tlvs);
    EXPECT_THROW(lldp_parser.parse(packet), std::runtime_error);
}

// 测试系统名称过长的情况 (通过公共接口测试)
// 测试各种Chassis ID子类型
TEST_F(lldp_test, parse_lldp_tlv_chassis_id_network_address) {
    // 网络地址格式: [subtype=5][addr_len=5][network_subtype=0][IPv4_bytes]
    std::string info_string = std::string("\x05\x05\x00\xC0\xA8\x01\x01", 7);  // subtype=5 + addr_len=5 + network_subtype=0 + IPv4
    dev::lldp_tlv tlv{dev::tlv_type::CHASSIS_ID_TLV, info_string};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("chassis_id"));
    EXPECT_EQ(result["chassis_id"], "192.168.1.1");
    EXPECT_EQ(result["chassis_id_subtype"], "NetworkAddr");
}

TEST_F(lldp_test, parse_lldp_tlv_chassis_id_interface_name) {
    std::string info_string = std::string("\x06", 1) + "eth0";  // 接口名称，subtype=6
    dev::lldp_tlv tlv{dev::tlv_type::CHASSIS_ID_TLV, info_string};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("chassis_id"));
    EXPECT_EQ(result["chassis_id"], "eth0");
    EXPECT_EQ(result["chassis_id_subtype"], "IfName");
}

TEST_F(lldp_test, parse_lldp_tlv_chassis_id_locally_assigned) {
    std::string info_string = std::string("\x07", 1) + "local123";  // 本地分配，subtype=7
    dev::lldp_tlv tlv{dev::tlv_type::CHASSIS_ID_TLV, info_string};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("chassis_id"));
    EXPECT_EQ(result["chassis_id"], "local123");
    EXPECT_EQ(result["chassis_id_subtype"], "LocalAssign");
}

// 测试各种Port ID子类型
TEST_F(lldp_test, parse_lldp_tlv_port_id_network_address) {
    // 网络地址格式: [subtype=4][addr_len=5][network_subtype=0][IPv4_bytes]
    std::string info_string = std::string("\x04\x05\x00\xC0\xA8\x01\x01", 7);  // subtype=4 + addr_len=5 + network_subtype=0 + IPv4
    dev::lldp_tlv tlv{dev::tlv_type::PORT_ID_TLV, info_string};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_EQ(result["port_id"], "192.168.1.1");
    EXPECT_EQ(result["port_id_subtype"], "NetworkAddr");
}

TEST_F(lldp_test, parse_lldp_tlv_port_id_interface_name) {
    std::string info_string = std::string("\x05", 1) + "eth1";  // 接口名称，subtype=5
    dev::lldp_tlv tlv{dev::tlv_type::PORT_ID_TLV, info_string};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_EQ(result["port_id"], "eth1");
    EXPECT_EQ(result["port_id_subtype"], "IfName");
}

TEST_F(lldp_test, parse_lldp_tlv_port_id_agent_circuit_id) {
    std::string info_string = std::string("\x06", 1) + "circuit123";  // 代理电路ID，subtype=6
    dev::lldp_tlv tlv{dev::tlv_type::PORT_ID_TLV, info_string};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("port_id"));
    EXPECT_EQ(result["port_id"], "circuit123");
    EXPECT_EQ(result["port_id_subtype"], "AgentId");
}

// 测试Org Specific TLV的各种情况
TEST_F(lldp_test, parse_lldp_tlv_org_specific_zero_vlan) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x80\xC2\x01\x00\x00", 6)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.contains("vlan_id"));
    EXPECT_EQ(result["vlan_id"], 0xFFFF);  // VLAN ID为0时应该返回0xFFFF
}

TEST_F(lldp_test, parse_lldp_tlv_org_specific_invalid_oui) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x00\x00\x01\x00\x64", 6)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.empty());  // 错误的OUI，不应该返回vlan_id
}

TEST_F(lldp_test, parse_lldp_tlv_org_specific_short_data) {
    dev::lldp_tlv tlv{dev::tlv_type::ORG_SPECIFIC_TLV, std::string("\x00\x80\xC2\x01\x00", 5)};
    auto result = lldp_parser.parse_lldp_tlv(tlv);

    EXPECT_TRUE(result.empty());  // 数据长度不够
}

} // namespace test_lldp
